<html><head><title>Simulate crosses and apply selection</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="Rchm.css">
</head>
<body>

<table width="100%"><tr><td>simLGS(LGS)</td><td align="right">R Documentation</td></tr></table><object type="application/x-oleobject" classid="clsid:1e2a7bd0-dab9-11d0-b93a-00c04fc99f9e">
<param name="keyword" value="R:   simLGS">
<param name="keyword" value=" Simulate crosses and apply selection">
</object>


<h2>Simulate crosses and apply selection</h2>


<h3>Description</h3>

<p>
<code>simLGS</code> generates a recombinant population with given genome and recombination map and applies selection at specified loci (see <code><a href="pcMap.html">pcMap</a></code> for a template of a map file). This is the most important function of the LGS package.
</p>


<h3>Usage</h3>

<pre>
simLGS(offspring = 50, fix.before.sel = FALSE, NoP1 = 10, NoP2 = 10, map = NULL, scenario = NULL, gen.dist = "k", kb2cM = 15)
</pre>


<h3>Arguments</h3>

<table summary="R argblock">
<tr valign="top"><td><code>offspring</code></td>
<td>
Number of progeny clones to be generated. </td></tr>
<tr valign="top"><td><code>fix.before.sel</code></td>
<td>
Should the number of clones be reached before or after selection? </td></tr>
<tr valign="top"><td><code>NoP1</code></td>
<td>
If numeric: number of parental parasites. If a matrix, the population to be used as parental population. </td></tr>
<tr valign="top"><td><code>NoP2</code></td>
<td>
Same as <code>NoP1</code> (i.e. the other parent). </td></tr>
<tr valign="top"><td><code>map</code></td>
<td>
Table with map specification and selection coefficients. </td></tr>
<tr valign="top"><td><code>scenario</code></td>
<td>
A column (name or index) specifying the selection coefficients at each locus. </td></tr>
<tr valign="top"><td><code>gen.dist</code></td>
<td>
Metrics of the user's genetic distances (see details). </td></tr>
<tr valign="top"><td><code>kb2cM</code></td>
<td>
Ratio kilobases/cM to convert physical distance to recombination frequency (if <code>gen.dist="phy"</code>). </td></tr>
</table>

<h3>Details</h3>

<p>
<code>simLGS</code> simulates random mating and recombiantion between two parental population that, by default, are polymorphic at all the loci specified in the map file <code>map</code>. By default, each parental individual in <code>NoP1</code> and  <code>NoP2</code> is represented by a vector of 0 and 1 alleles, respectively. 
</p>
<p>
Note that the absolute number in <code>NoP1</code> and  <code>NoP2</code> is irrelevant, what matters is their ratio.
</p>
<p>
<code>NoP1</code> and  <code>NoP2</code> can be matrices (rows= individuals and columns= loci) either used specified or obtained by other functions.
</p>
<p>
If <code>fix.before.sel</code> is set to <code>TRUE</code>, simLGS will generate <code>offspring</code> and then apply selection. If <code>fix.before.sel</code>=<code>FALSE</code>, simLGS will keep generate and select until <code>offspring</code> number is reached.
</p>
<p>
<code>scenario</code> must be a column present in <code>map</code>. See example map file <code><a href="pcMap.html">pcMap</a></code>.
</p>
<p>
<code>gen.dist</code> specifies which measure of marker distances is being used in <code>map</code>. It must be one of the following: <code>"k"</code> for Kosambi centi-morgan (the default), <code>"h"</code> for Haldane cM, <code>"rf"</code> for recombination frequency, <code>"phy"</code> for physical distance. If <code>"phy"</code> is chosen, <code>kb2cM</code> must be specified. 
</p>
<p>
The default of kb2cm is 15kb/cM and corresponds approximately to the ratio found in P. chabaudi.
</p>


<h3>Value</h3>

<p>
A list of class <code>LGS</code> with components:
</p>
<table summary="R argblock">
<tr valign="top"><td><code>recPop </code></td>
<td>
A matrix of recombinant (progeny) population before selection.</td></tr>
<tr valign="top"><td><code>ParPop </code></td>
<td>
Matrix of the parental population.</td></tr>
<tr valign="top"><td><code>selPop </code></td>
<td>
Matrix of progeny population (<code>recPop</code>) after selection.</td></tr>
<tr valign="top"><td><code>ChrMap</code></td>
<td>
Dataframe corresponding to <code>map</code> plus a column for cumulative distances (<code>CumDist</code>) and a column of allele ratios (<code>LGS</code>).</td></tr>
</table>
<p>

Matrices of populations have: rows= individuals (haplotypes), columns= loci.</p>

<h3>Author(s)</h3>

<p>
Dario Beraldi &lt;<a href="mailto:dario.beraldi@ed.ac.uk">dario.beraldi@ed.ac.uk</a>&gt;
</p>


<h3>See Also</h3>

<p>
<code><a href="plotLGS.html">plotLGS</a></code> to plot the LGS profile; <code><a href="biasLGS.html">biasLGS</a></code>, etc.
</p>


<h3>Examples</h3>

<pre>
# Generate a map dataframe with 3 chromosomes, 5 markers/chromosomes, 10cM marker spacing.
# Third marker on chromosome 2 is under selection
SelCoef&lt;- rep(0,15)
SelCoef[8]&lt;- -0.99
(genMap&lt;- data.frame(Chr= rep(1:3, each=5), Locus= seq(1,15),uCumDist= seq(0, 140, length.out=15), SelCoef= SelCoef))
lgs1&lt;- simLGS(offspring =100, map= genMap)
# Plot LGS profile
plotLGS(lgs1)

# Import P. chabaudi map
data(pcMap)
# One locus under selection, sensitive allele is counterselected in 99
lgs99&lt;- simLGS(map=pcMap, scenario= "EqualFitness99", gen.dist="phy") # Physical distances
plotLGS(lgs99)
# Same as above but selection is 80
lgs80&lt;- simLGS(map=pcMap, scenario= "EqualFitness80", gen.dist="phy") # Physical distances
plotLGS(lgs80, add=TRUE, col="blue")
</pre>



<hr><div align="center">[Package <em>LGS</em> version 0.9 <a href="00Index.html">Index]</a></div>

</body></html>
